import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:x_core/x_core.dart';
import 'package:x_project/x_project.dart';

bool handleException(NetException exception,
    {bool Function(NetException)? onError}) {
  if (onError?.call(exception) == true) {
    return true;
  }

  if (exception.code == NetException.unauthorized) {
    ///todo 处理去登录
    Get.toNamed(CommonRouter.login);
    return true;
  }
  EasyLoading.showError(exception.message ?? NetException.unknownExceptionStr);

  return false;
}
